package com.example.hfweather.adapter

import android.content.Context
import android.view.ViewGroup
import com.chad.library.adapter4.BaseQuickAdapter
import com.chad.library.adapter4.viewholder.QuickViewHolder
import com.example.hfweather.R
import com.qweather.sdk.response.indices.IndicesDaily

/**
 * 天气指数适配器
 */
class WeatherIndexAdapter : BaseQuickAdapter<IndicesDaily, QuickViewHolder>() {
    override fun onBindViewHolder(
        holder: QuickViewHolder,
        position: Int,
        item: IndicesDaily?
    ) {
        holder.run {
            setText(R.id.tv_weather_index_name, item?.name)
            setText(R.id.tv_weather_index_value, item?.level + " / " + item?.category)
            setText(R.id.tv_weather_index_advice, item?.text)
        }
    }

    override fun onCreateViewHolder(
        context: Context,
        parent: ViewGroup,
        viewType: Int
    ): QuickViewHolder {
        return QuickViewHolder(R.layout.item_weather_others, parent)
    }


}